package com.example.bzh.gamecat.httputils.societyutils;

import com.example.bzh.gamecat.bean.SocietyAllPlayBean;
import com.example.bzh.gamecat.bean.SocietyBabyBean;
import com.example.bzh.gamecat.httputils.RetrofitHelper;
import com.example.bzh.gamecat.ui.society.babysociety.ISocietyBabyService;

import java.util.HashMap;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by MyPC on 2016/8/13.
 */
public class SocietyBabyHttpUtil {

    private static SocietyBabyHttpUtil instance;

    private SocietyBabyHttpUtil(){
    }

    public static synchronized SocietyBabyHttpUtil getInstance(){
        if (instance == null){
            instance = new SocietyBabyHttpUtil();
        }
        return instance;
    }

    public interface HttpCallBack<T>{
        public void onSucess(T t);

        public void onFail();
    }

    public void getSociety(HashMap<String,String> params, final HttpCallBack<SocietyBabyBean> recommendBeanHttpCallBack){
        Call<SocietyBabyBean> beanCall = RetrofitHelper
                .getInstance()
                .createRetrofitService(ISocietyBabyService.class)
                .getSocietyBabyBean(params);
        beanCall.enqueue(new Callback<SocietyBabyBean>() {
            @Override
            public void onResponse(Call<SocietyBabyBean> call, Response<SocietyBabyBean> response) {
//                Log.e("TAG","AAAA.........."+response.body().getData().getActiveList().size());
                recommendBeanHttpCallBack.onSucess(response.body());
            }

            @Override
            public void onFailure(Call<SocietyBabyBean> call, Throwable t) {
                recommendBeanHttpCallBack.onFail();
            }
        });
    }
}
